<!--  -->
<template>
  <div class="my-twocark">
    <div class="main">
      <div class="my-cark-header">
        <div class="header-title">{{ dataList.title }}</div>
        <div class="header-unit">{{ dataList.unit }}</div>
      </div>

      <vue-seamless-scroll
        :data="dataList.dataList"
        class="my-cark-main"
        ref="scrollContainer"
        :class-option="defaultOption"
      >
        <div
          class="cark-main-list"
          v-for="(item, index) in dataList.dataList"
          :key="index"
        >
          <!-- :class="{ one: index % 2 == 0 }" -->
          <div class="rank">{{ item.rank }}</div>
          <div class="name" :style="{ color: item.myColor }">
            {{ item.name }}
          </div>
          <div class="single" :style="{ color: item.myColor }">
            {{ item.single }}
          </div>
        </div>
      </vue-seamless-scroll>
    </div>
  </div>
</template>
<script>
import vueSeamlessScroll from "vue-seamless-scroll";
export default {
  name: "my-twocark",
  components: {
    vueSeamlessScroll,
  },
  props: {
    dataList: { type: Object, default: () => ({}) },
    myStyle: { type: Object, default: () => ({}) },
  },
  data() {
    return {
      // timer: 0,
      // scrollPosition: 0,
      step: 0.2,
    };
  },
  computed: {
    defaultOption () {
      return {
        step: 0.2, // 数值越大速度滚动越快
        limitMoveNum: 2, // 开始无缝滚动的数据量 this.dataList.length
        hoverStop: true, // 是否开启鼠标悬停stop
        direction: 1, // 0向下 1向上 2向左 3向右
        openWatch: true, // 开启数据实时监控刷新dom
        singleHeight: 0, // 单步运动停止的高度(默认值0是无缝不停止的滚动) direction => 0/1
        singleWidth: 0, // 单步运动停止的宽度(默认值0是无缝不停止的滚动) direction => 2/3
        waitTime: 1000 // 单步运动停止的时间(默认值1000ms)
      }
    }
  },
  methods: {
    // scrollToBottom() {
    //   this.$refs.scrollContainer.scrollTop =
    //     this.$refs.scrollContainer.scrollHeight;
    // },
  },

  mounted() {
    // this.$nextTick(() => {
    //   this.scrollToBottom();
    // });
    // this.timer = setInterval(() => {
    //   this.scrollPosition += 1;
    //   if (this.scrollPosition >= this.$refs.scrollContainer.scrollHeight) {
    //     this.scrollPosition = 0;
    //   }
    //   this.$refs.scrollContainer.scrollTop = this.scrollPosition;
    // }, 50);
  },

  destroyed() {
    // clearInterval(this.timer);
  },
};
</script>
<style scoped lang="scss">
.my-twocark {
  margin-top: 10px;
  width: 27.3125rem;
  height: 16.5625rem;
  background: rgba(16, 27, 168, 0.15);
  border: 2px solid;
  border-image: linear-gradient(-90deg, #070f63, #3d61f3) 2 2;
  box-shadow: 0px 6px 10px 0px rgba(0, 0, 0, 0.15);
  display: flex;
  justify-content: center;
  .main {
    width: 100%;
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    // overflow: auto;
    ::-webkit-scrollbar-track {
      background-color: rgba(8, 41, 128, 0.5);
    }
    ::-webkit-scrollbar {
      width: 6px; /* 设置滚动条宽度 */
    }
    ::-webkit-scrollbar-thumb:hover {
      background-color: #082980;
    }
    .my-cark-header {
      height: 15%;
      width: 90%;
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      overflow: auto;
      .header-unit,
      .header-title {
        font-size: 1rem;
        font-family: PingFang SC;
        font-weight: 500;
        color: #20cefa;
        line-height: 19px;
      }
    }
    .my-cark-main {
      transform: translateY(-0px);
      height: 80%;
      width: 100%;
      overflow: hidden;
      .cark-main-list {
        height: 17%;
        line-height: 2.125rem;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        color: #9ec7ff;
        border-bottom: 1px solid #006273;
      }
    }
  }
}
.rank {
  width: 26px;
  height: 22px;
  display: flex;
  justify-content: center;
  align-content: center;
  margin-left: 1.25rem;
  margin-bottom: 0.5rem;
  flex-shrink: 0;
  // line-height: 1rem;
}
.name {
  font-size: 1rem;
  font-family: PingFang SC;
  font-weight: 400;
  opacity: 0.8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  flex: 1;
}
.single {
  font-size: 1rem;
  font-family: PingFang SC;
  font-weight: 400;
  margin-right: 10%;
  flex-shrink: 0;
}

.one {
  background: #122799;
}
</style>
